import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
// 引入字体图标
import './assets/font/iconfont.css'
// 引入全局样式
import './assets/css/global.css'
import axios from 'axios'
import zkTable from 'vue-table-with-tree-grid'
// 配置请求的根路径
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
// axios拦截请求，config是请求对象
axios.interceptors.request.use(config => {
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
})
// 处理事件格式过滤器
Vue.filter('timeHandle', function (time) {
  const dr = new Date(time)

  const y = dr.getFullYear()
  const m = (dr.getMonth() + 1 + '').padStart(2, '0')
  const d = (dr.getDate() + '').padStart(2, '0')

  const hh = (dr.getHours() + '').padStart(2, '0')
  const mm = (dr.getMinutes() + '').padStart(2, '0')
  const ss = (dr.getSeconds() + '').padStart(2, '0')

  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})
Vue.component(zkTable.name, zkTable)
// 挂载axios到vue
Vue.prototype.$http = axios

Vue.config.productionTip = false

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
